﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.OleDb;
using System.Net.Mail;
using System.Net;


public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string degergoster =  Request.QueryString["sayfa"];
        if (degergoster == "kasko")
        {

            MultiView1.ActiveViewIndex = 0;
        }
        if (degergoster == "saglik")
        {

            MultiView1.ActiveViewIndex =1;
        }
 if (degergoster == "konut")
        {

            MultiView1.ActiveViewIndex = 2;
        }



 if (degergoster == "sil")
 {

     MultiView1.ActiveViewIndex = 3;
 }
 if (degergoster == "istf")
 {

     MultiView1.ActiveViewIndex = 4;
 }


 if (degergoster == "dask")
 {

     MultiView1.ActiveViewIndex = 5;
 }

 if (degergoster == "policevadezaman")
 {

     MultiView1.ActiveViewIndex = 6;
 }
 if (degergoster == "formislemtamam")
 {

     MultiView1.ActiveViewIndex = 7;
 }

    }
    protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)
    {

    }
    protected void FormView1_ItemInserting1(object sender, FormViewInsertEventArgs e)
    {

    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
       
        OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["acsbagla"].ConnectionString);

        if (con.State == ConnectionState.Closed)
        {
            con.Open();
        }
        OleDbCommand komutsec = new OleDbCommand("DELETE from tblmusteri where userid="+Session.Contents["UID"].ToString(), con);
      
        komutsec.ExecuteNonQuery();
        con.Close();
        Response.Redirect("sayfagoster.aspx?sayfa=sil");
        Response.End();
    }
    protected void LinkButton2_Click1(object sender, EventArgs e)
    {
       LinkButton2_Click(sender, e);

    }
    protected void LinkButton2_Click2(object sender, EventArgs e)
    {
        LinkButton2_Click(sender, e);
    }
    protected void FormView5_PageIndexChanging(object sender, FormViewPageEventArgs e)
    {

    }

    protected void FormView6_PageIndexChanging(object sender, FormViewPageEventArgs e)
    {

    }
    protected void lbutonpolicezaman2_Click(object sender, EventArgs e)
    {
        OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["acsbagla"].ConnectionString);

        if (con.State == ConnectionState.Closed)
        {
            con.Open();
        }
        OleDbCommand komutsec = new OleDbCommand("DELETE from tblpolzamangelen where pid=" + Session.Contents["UID"].ToString(), con);

        komutsec.ExecuteNonQuery();
        con.Close();
        Response.Redirect("sayfagoster.aspx?sayfa=sil");
        Response.End();
    }
    protected void FormView1_PageIndexChanging(object sender, FormViewPageEventArgs e)
    {

    }
    protected void FormView3_PageIndexChanging(object sender, FormViewPageEventArgs e)
    {

    }
    MailMessage oMsg = new MailMessage();
    public static string StrBody;
  
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["acsbagla"].ConnectionString);

        if (con.State == ConnectionState.Closed)
        {
            con.Open();
        }


        OleDbCommand kaskookucmd = new OleDbCommand("SELECT tblmusteri.userid, tblmusteri.adisoyadi, tblmusteri.eposta, tblmusteri.tckimlikno, tblmusteri.vergikimlikno, tblmusteri.gsm, tblmusteri.tel, tblmusteri.faxno, tblmusteri.teklifsirketi, tblmusteri.tekliftarihi, tblkasko.plakano, tblkasko.aracmarka, tblkasko.aracmodel, tblkasko.modelyil, tblkasko.ikametil, tblkasko.plakail, tblkasko.ksekli, tblkasko.oacente, tblkasko.opoliceno, tblkasko.obaslangictarihi, tblkasko.obitistarihi, tblkasko.oyenilemeno, tblkasko.kveyat, tblkasko.hsrsizind, tblkasko.meslkind,tblkasko.meslek FROM (tblmusteri INNER JOIN tblkasko ON tblmusteri.userid = tblkasko.userid) WHERE  tblmusteri.userid=" + Session.Contents["UID"].ToString(), con);
        OleDbDataReader kaskooku = kaskookucmd.ExecuteReader();
        if (kaskooku.Read())
        {


            oMsg.From = new System.Net.Mail.MailAddress("basvuru@acsigorta.com.tr");
            oMsg.To.Add("basvuru@acsigorta.com.tr");
            oMsg.Subject =kaskooku[22].ToString() + "Teklif Formu";
            oMsg.IsBodyHtml = true;
            StrBody = "<html><body><b>Sayın Acsigorta Yöneticisi; </b>" +
                  "<p><b><font color=\"red\"> " + kaskooku[1].ToString() + "</font></b>tarafından doldurulan formun bilgileri aşağıda yeralmaktadır" + "</p>" +
                 
                  "<p>Teklif tarihi:" + kaskooku[9].ToString() + "</p>" +
                  "<p><b><font color=\"red\">KİŞİSEL BİLGİLER</font></b>" + "</p>" +
                  "<p>Adı Soyadı:" + kaskooku[1].ToString() + "</p>" +
                  "<p>Email:" + kaskooku[2].ToString() + "</p>" +
                  "<p>Tc kimlik numarası:" + kaskooku[3].ToString() + "</p>" +
                  "<p>Vergi kimlik numarası:" + kaskooku[4].ToString() + "</p>" +
                  "<p>Gsm:" + kaskooku[5].ToString() + "</p>" +
                  "<p>Telefon:" + kaskooku[6].ToString() + "</p>" +
                  "<p>Fax no:" + kaskooku[7].ToString() + "</p>" +
                  "<p>Plakano:" + kaskooku[10].ToString() + "</p>" +
                  "<p>Markası:" + kaskooku[11].ToString() + "</p>" +
                  "<p>Tipi-Modeli:" + kaskooku[12].ToString() + "</p>" +
                  "<p>Model Yılı:" + kaskooku[13].ToString() + "</p>" +
                  "<p>Sigortanın İkamet İli:" + kaskooku[14].ToString() + "</p>" +
                  "<p>Aracın Plaka Kayıt İli:" + kaskooku[15].ToString() + "</p>" +
                  "<p>Kullanım Şekli:" + kaskooku[16].ToString() + "</p>" +

                  "<p>Hasarsızlık İndirimi:" + kaskooku[23].ToString() + "</p>" +
                  "<p>Meslek İndirimi:" + kaskooku[24].ToString() + "</p>" +
                  "<p>Mesleği:" + kaskooku[25].ToString() + "</p>" +
                  " <p><b><font color=\"red\">ÖNCEKİ POLİÇE BİLGİLERİ</font></b>" + "</p>" +
                  "<p>Acente:" + kaskooku[17].ToString() + "</p>" +
                  "<p>Poliçe No:" + kaskooku[18].ToString() + "</p>" +
                  "<p>Yenileme No:" + kaskooku[21].ToString() + "</p>" +
                  "<p>Başlangıç Tarihi:" + kaskooku[19].ToString() + "</p>" +
                  "<p>Bitiş Tarihi:" + kaskooku[20].ToString() + "</p>" +
                  
             "</body></html>";

            oMsg.Body = StrBody;


            SmtpClient emailClient = new System.Net.Mail.SmtpClient("mail.acsigorta.com.tr");

            NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("basvuru@acsigorta.com.tr", "basvur123");
            emailClient.UseDefaultCredentials = true;
            emailClient.Credentials = SMTPUserInfo;
            emailClient.Send(oMsg);
            kaskooku.Close();
            con.Close();
            Response.Redirect("sayfagoster.aspx?sayfa=formislemtamam");
            Response.End();
        }
    }
    protected void LinkButton1_Click1(object sender, EventArgs e)
    {
        OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["acsbagla"].ConnectionString);

        if (con.State == ConnectionState.Closed)
        {
            con.Open();
        }


        OleDbCommand konutokucmd = new OleDbCommand("SELECT tblmusteri.userid, tblmusteri.adisoyadi, tblmusteri.eposta, tblmusteri.tckimlikno, tblmusteri.vergikimlikno, tblmusteri.gsm, tblmusteri.tel, tblmusteri.faxno, tblmusteri.teklifsirketi, tblmusteri.tekliftarihi, tblkonut.konutil, tblkonut.konutilce, tblkonut.konutyapi, tblkonut.odemetip, tblkonut.odemetaksit, tblkonut.binabedeli, tblkonut.esyabedeli, tblkonut.cambedeli, tblkonut.daskpoliceno, tblkonut.daskbitistarihi, tblkonut.daskbedeli, tblkonut.guvenlik FROM (tblmusteri INNER JOIN tblkonut ON tblmusteri.userid = tblkonut.userid) WHERE  tblmusteri.userid=" + Session.Contents["UID"].ToString(), con);
        OleDbDataReader konutoku = konutokucmd.ExecuteReader();
        if (konutoku.Read())
        {


            oMsg.From = new System.Net.Mail.MailAddress("basvuru@acsigorta.com.tr");
            oMsg.To.Add("basvuru@acsigorta.com.tr");
            oMsg.Subject = "Konut Teklif Formu";
            oMsg.IsBodyHtml = true;
            StrBody = "<html><body><b>Sayın Acsigorta Yöneticisi; </b>" +
                  "<p><b><font color=\"red\"> " + konutoku[1].ToString() + "</font></b>tarafından doldurulan formun bilgileri aşağıda yeralmaktadır" + "</p>" +

                  "<p>Teklif tarihi:" + konutoku[9].ToString() + "</p>" +
                  "<p><b><font color=\"red\">KİŞİSEL BİLGİLER</font></b>" + "</p>" +
                  "<p>Adı Soyadı:" + konutoku[1].ToString() + "</p>" +
                  "<p>Email:" + konutoku[2].ToString() + "</p>" +
                  "<p>Tc kimlik numarası:" + konutoku[3].ToString() + "</p>" +
                  "<p>Vergi kimlik numarası:" + konutoku[4].ToString() + "</p>" +
                  "<p>Gsm:" + konutoku[5].ToString() + "</p>" +
                  "<p>Telefon:" + konutoku[6].ToString() + "</p>" +
                  "<p>Fax no:" + konutoku[7].ToString() + "</p>" +

                  " <p><b><font color=\"red\">KONUT BİLGİLERİNİZ</font></b>" + "</p>" +
                  "<p>İl:" + konutoku[10].ToString() + "</p>" +
                  "<p>İlçe:" + konutoku[11].ToString() + "</p>" +
                  "<p>Yapı:" + konutoku[12].ToString() + "</p>" +
                  "<p>Bina Bedeli:" + konutoku[15].ToString() + "</p>" +
                  "<p>Eşya Bedeli:" + konutoku[16].ToString() + "</p>" +
                  "<p>Cam Bedeli:" + konutoku[17].ToString() + "</p>" +
                 

                   " <p><b><font color=\"red\">DASK POLİÇE BİLGİLERİNİZ</font></b>" + "</p>" +
                  "<p>DASK Poliçe No:" + konutoku[18].ToString() + "</p>" +
                  "<p>DASK Bitiş Tarihi:" + konutoku[19].ToString() + "</p>" +
                  "<p>DASK Bedeli:" + konutoku[20].ToString() + "</p>" +
                  " <p><b><font color=\"red\">GÜVENLİK ÖNLEMLERİNİZ</font></b>" + "</p>" +

                  "<p>Güvenlik:" + konutoku[21].ToString() + "</p>" +
                   


             "</body></html>";

            oMsg.Body = StrBody;


            SmtpClient emailClient = new System.Net.Mail.SmtpClient("mail.acsigorta.com.tr");

            NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("basvuru@acsigorta.com.tr", "basvur123");
            emailClient.UseDefaultCredentials = true;
            emailClient.Credentials = SMTPUserInfo;
            emailClient.Send(oMsg);
            konutoku.Close();
            con.Close();
            Response.Redirect("sayfagoster.aspx?sayfa=formislemtamam");
            Response.End();
        }
    }
    protected void LinkButton1_Click2(object sender, EventArgs e)
    {

        OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["acsbagla"].ConnectionString);

        if (con.State == ConnectionState.Closed)
        {
            con.Open();
        }


        OleDbCommand saglikokucmd = new OleDbCommand("SELECT tblmusteri.userid, tblmusteri.adisoyadi, tblmusteri.eposta, tblmusteri.tckimlikno, tblmusteri.vergikimlikno, tblmusteri.gsm, tblmusteri.tel, tblmusteri.faxno, tblmusteri.teklifsirketi, tblmusteri.tekliftarihi, tblsaglik.cinsiyet, tblsaglik.dogumtarihi, tblsaglik.kangrubu, tblsaglik.boy, tblsaglik.kilo, tblsaglik.odemetip, tblsaglik.odemetaksit FROM (tblmusteri INNER JOIN tblsaglik ON tblmusteri.userid = tblsaglik.userid) WHERE  tblmusteri.userid=" + Session.Contents["UID"].ToString(), con);
        OleDbDataReader saglikoku = saglikokucmd.ExecuteReader();
        if (saglikoku.Read())
        {


            oMsg.From = new System.Net.Mail.MailAddress("basvuru@acsigorta.com.tr");
            oMsg.To.Add("basvuru@acsigorta.com.tr");
            oMsg.Subject = "Sağlık Teklif Formu";
            oMsg.IsBodyHtml = true;
            StrBody = "<html><body><b>Sayın Acsigorta Yöneticisi; </b>" +
                  "<p><b><font color=\"red\"> " + saglikoku[1].ToString() + "</font></b>tarafından doldurulan formun bilgileri aşağıda yeralmaktadır" + "</p>" +

                  "<p>Teklif tarihi:" + saglikoku[9].ToString() + "</p>" +
                  "<p><b><font color=\"red\">KİŞİSEL BİLGİLER</font></b>" + "</p>" +
                  "<p>Adı Soyadı:" + saglikoku[1].ToString() + "</p>" +
                  "<p>Email:" + saglikoku[2].ToString() + "</p>" +
                  "<p>Tc kimlik numarası:" + saglikoku[3].ToString() + "</p>" +
                  
                  "<p>Gsm:" + saglikoku[5].ToString() + "</p>" +
                  "<p>Telefon:" + saglikoku[6].ToString() + "</p>" +
                  "<p>Fax no:" + saglikoku[7].ToString() + "</p>" +

                  
                  "<p>Cinsiyet:" + saglikoku[10].ToString() + "</p>" +
                  "<p>Doğum Tarihi:" + saglikoku[11].ToString() + "</p>" +
              
             "</body></html>";

            oMsg.Body = StrBody;


            SmtpClient emailClient = new System.Net.Mail.SmtpClient("mail.acsigorta.com.tr");

            NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("basvuru@acsigorta.com.tr", "basvur123");
            emailClient.UseDefaultCredentials = true;
            emailClient.Credentials = SMTPUserInfo;
            emailClient.Send(oMsg);
            saglikoku.Close();
            con.Close();
            Response.Redirect("sayfagoster.aspx?sayfa=formislemtamam");
            Response.End();
        }

    }
    protected void lbutonpolicezaman_Click(object sender, EventArgs e)
    {
        OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["acsbagla"].ConnectionString);

        if (con.State == ConnectionState.Closed)
        {
            con.Open();
        }


        OleDbCommand polzamanokucmd = new OleDbCommand("SELECT * from tblpolzamangelen WHERE  pid=" + Session.Contents["UID"].ToString(), con);
        OleDbDataReader polzamanoku = polzamanokucmd.ExecuteReader();
        if (polzamanoku.Read())
        {


            oMsg.From = new System.Net.Mail.MailAddress("basvuru@acsigorta.com.tr");
            oMsg.To.Add("basvuru@acsigorta.com.tr");
            oMsg.Subject = "Poliçe Zaman Hatırlatma Teklif Formu";
            oMsg.IsBodyHtml = true;
            StrBody = "<html><body><b>Sayın Acsigorta Yöneticisi; </b>" +
                  "<p><b><font color=\"red\"> " + polzamanoku[1].ToString() + "</font></b>tarafından doldurulan formun bilgileri aşağıda yeralmaktadır" + "</p>" +

                  "<p>Teklif tarihi:" + polzamanoku[8].ToString() + "</p>" +
                  "<p><b><font color=\"red\">KİŞİSEL BİLGİLER</font></b>" + "</p>" +
                  "<p>Adı Soyadı:" + polzamanoku[1].ToString() + "</p>" +
                  "<p>Profil:" + polzamanoku[2].ToString() + "</p>" +
                  "<p>Firma Adı:" + polzamanoku[3].ToString() + "</p>" +

                  "<p>Email:" + polzamanoku[4].ToString() + "</p>" +
                 
                  "<p>İş tel numarası:" + polzamanoku[5].ToString() + "</p>" +


                  "<p>Cep telefon numarası:" + polzamanoku[6].ToString() + "</p>" +
                  "<p>Poliçe türü:" + polzamanoku[7].ToString() + "</p>" +
"<p>Mesajı:" + polzamanoku[9].ToString() + "</p>" +

             "</body></html>";

            oMsg.Body = StrBody;


            SmtpClient emailClient = new System.Net.Mail.SmtpClient("mail.acsigorta.com.tr");

            NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("basvuru@acsigorta.com.tr", "basvur123");
            emailClient.UseDefaultCredentials = true;
            emailClient.Credentials = SMTPUserInfo;
            emailClient.Send(oMsg);
            polzamanoku.Close();
            con.Close();
            Response.Redirect("sayfagoster.aspx?sayfa=formislemtamam");
            Response.End();
        }


    }
}
